package com.ihelp.rest.base.po;

import java.util.Collections;
import java.util.List;

/**
 * 分页
* @version
 */
public class Page<E> {
	
	private List<E> items;// 当前页包含的记录列表
	
	private int totalCount; //总记录数
	
	private int pageSize = 10; //每页显示行数(默认10)
	
	private int currentPage = 1; //当前页数(默认1)

	public List<E> getItems() {
		return this.items == null ? Collections.<E> emptyList() : this.items;
	}

	public void setItems(List<E> items) {
		this.items = items;
	}

	public int getTotalCount() {
		return totalCount;
	}
	
	/**
	 * 根据pageNo和pageSize计算当前页第一条记录在总结果集中的位置,序号从1开始.
	 */
	public int getFirstOfPage() {
		return ((currentPage - 1) * pageSize) + 1;
	}

	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

}
